package com.gh.service.impl;

import com.gh.entity.Student;
import com.gh.entity.StudentExample;
import com.gh.mapper.StudentMapper;
import com.gh.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper mapper;

    @Override
    public List<Student> findAll(List<Integer> list) throws Exception {
        List<Student> list2 = mapper.findAll(list);
        return list2;
    }

    @Override
    public Integer findTotal() throws Exception {
        Integer count = mapper.findTotal();
        return count;
    }

    @Override
    public void add(Student student) throws Exception {
        mapper.insert(student);
    }

    @Override
    public void update(Student student) throws Exception {
        mapper.update(student);
    }

    @Override
    public void delete(int id) throws Exception {
        mapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<Student> findByAddress(String address) throws Exception {
        List<Student> list = mapper.findByAddress(address);
        return list;
    }

    @Override
    public List<Student> findByName(String name) throws Exception {
        List<Student> list = mapper.findByName(name);
        return list;
    }

    @Override
    public List<Student> findById(int id) throws Exception {
        List<Student> list = mapper.findById(id);
        return list;
    }
}
